#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool compare(int a, int b)
    {
        return a > b;
    }
    int maxArea(vector<int>& height) {
        int max = 0;
        int i = 0;
        int v;
        int left = 0, right = height.size() - 1;
        while (left < right)
        {
            int l = right - left;
            if (compare(height[left], height[right]))
            {
                v = l * height[right];
                right--;
                if (!compare(max, v))
                    max = v;
            }
            else
            {
                v = l * height[left];
                left++;
                if (!compare(max, v))
                    max = v;
            }
        }
        return max;
    }
};


class Solution {
public:
    int happy(int n) {
        int sum = 0;
        while (n) {
            int t = n % 10;
            sum += t * t;
            n /= 10;
        }
        return sum;
    }

    bool isHappy(int n) {
        int slow = n, fast = happy(n);
        while (slow != fast) {
            slow = happy(slow);
            fast = happy(happy(fast));
        }
        return slow == 1;
    }
};